package com.homedo.core.common.util;

import com.homedo.core.common.base.dto.Meta;
import com.homedo.core.common.exception.BizException;

/**
 * @author: zhaoxudong
 * @date: 2018/3/11 16:27
 * @Description: 参数校验工具
 */
public class ParamCheckUtil {

    /**
     * 校验分页参数
     * @param pageNum
     * @param pageSize
     */
    public static void checkPageParam( Integer pageNum,Integer pageSize) {
        if(pageNum==null||pageNum<=0){
            throw new BizException(Meta.CODE_451.getCode(),"当前页码必须大于0");
        }
        if(pageSize==null||pageSize<=0){
            throw new BizException(Meta.CODE_451.getCode(),"每页数量必须大于等于0");
        }
    }

    /**
     * 校验userId
     * @param userId
     */
    public static void checkUserId(Integer userId){
        if(userId==null||userId<=0){
            throw new BizException(Meta.CODE_451.getCode(),"userId不合规");
        }
    }

    /**
     * 校验listId
     * @param listId
     */
    public static void checkListId(Integer listId){
        if(listId==null||listId<=0){
            throw new BizException(Meta.CODE_451.getCode(),"listId不合规");
        }
    }

    public static void checkLongUserId(Long userId) {
        if(userId==null||userId<=0){
            throw new BizException(Meta.CODE_451.getCode(),"用户id不合规");
        }
    }
}
